<!DOCTYPE html>
<html>
<head>
    <title>我的点赞列表</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/plugins/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/plugins/jquery/jquery.min.js"></script>
    <script src="/js/plugins/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/userTravels.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script>
        $(function () {
            var user = JSON.parse(sessionStorage.getItem("user"));
            var userId = user.id;
            //首先我们需要获取当前页的标签
            var currentInput = $('#currentPage');
            //因为我们手机滚动之前的数据就没有了,只有当前查出来的不合理
            var arr = [];
            var pages = 1;

            function query() {
                //获取当前页
                var currentPage = currentInput.val();
                $.get('/allMessages/' + userId, {currentPage: currentPage}, function (data) {
                    console.log(data);
                    pages = data.likePageInfo.pages;
                    console.log(pages);
                    //把两个数组的数据合并在一起,就可以滚动了
                    $.merge(arr, data.likePageInfo.list);
                    var json = {list: arr};
                    $('.container').renderValues(json, {
                        getHref: function (item, value) {
                            var href = $(item).data("href");
                            $(item).attr("href", href + value);
                        }
                    });
                });
                currentInput.val(parseInt(currentPage) + 1);
            }
            query();
            $('._j_add_more_button').click(function () {
                var currentPage = currentInput.val();
                if (currentPage <= pages) {
                    query();
                } else {
                    $(document).dialog({
                        type: 'notice',
                        infoText: '没有更多点赞信息了!!!',
                        autoClose: 1000
                    });
                }
            })
        })
    </script>
</head>

<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="/mine/message.html">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
            <span>我的点赞列表</span>
        </div>
        <div class="col"></div>
    </div>
</div>

<input type="hidden" name="currentPage" id="currentPage" value="1"/>
<div class="container">
    <hr style="height:1px;border:none;border-top:1px solid #555555;" />
    <div render-loop="list">
        <div class="row info">
            <div class="col-3" style="margin-right: 25px;">
                <a data-href="/userProfiles.html?authorId=" render-key="list.user.id" render-fun="getHref" class="aui-news-item">
                <img class="rounded-circle" render-src="list.user.headImgUrl" style="width: 90%">
                </a>
                <span style="color: red">&nbsp;&nbsp;&nbsp;赞了你</span>
            </div>
            <div class="col-8">
                <ul class="list-inline">
                    <li class="list-inline-item">
                        <small render-html="list.user.nickName"></small>
                    </li>
                    <li class="list-inline-item">
                        <small>关注<span render-html="list.user.follow"></span></small>
                    </li>
                    <li class="list-inline-item">
                        <small>粉丝<span render-html="list.user.fans"></span></small>
                    </li>
                </ul>

                <a data-href="/travelContent.html?id=" render-key="list.travel.id" render-fun="getHref" class="aui-news-item" style="color: blue">查看点赞游记详情</a>
                <div>
                </div>
                <hr style="height:1px;border:none;border-top:1px solid #555555;" />
            </div>
        </div>
    </div>
    <hr size="50px" color="black">
</div>
<div class="aui-news-box" style="text-align: center">
    <a class="more-list _j_add_more_button">更多点赞信息</a>
</div>
</body>
</html>
